package com.kongchengji.spider.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Logger;

public class LaunchVPNUtil {
    private LaunchVPNUtil(){}
    public static LaunchVPNUtil getInstance(){
        return new LaunchVPNUtil();
    }
    public  String executeCmd(String command) {
        Logger log = Logger.getLogger("executeCmd");
        log.info("--------" + command);
        Runtime runtime = Runtime.getRuntime();
        Process process;
        StringBuilder build;
        try {
            process =  runtime.exec("cmd /c " + command);
            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "gbk"));
            String line;
            build = new StringBuilder();
            while ((line = br.readLine()) != null) {
                log.info(line);
                build.append(line);
            }
            return build.toString();

        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

}
